
  //判断浏览器是否支持placeholder属性
  var supportPlaceholder='placeholder'in document.createElement('input'),
 
  placeholder = function(input){
 
    var text = input.attr('placeholder');
    var defaultValue = input.attr('value');
    if(!defaultValue){
      input.val(text).addClass("phcolor");
    }
 
    input.focus(function(){
 
      if(input.val() == text){
   
        $(this).val("");
      }
    });
 
  
    input.blur(function(){
 
      if(input.val() == ""){
       
        $(this).val(text).addClass("phcolor");
      }
    });
 
    //输入的字符不为灰色
    input.keydown(function(){
  
      $(this).removeClass("phcolor");
    });
  };
 
  placeholderPWD = function(input){
	  
	  var pwdField    = $(input);
      var pwdVal      = pwdField.attr('placeholder');
      pwdField.after('<input  class="login-input" type="text" value='+pwdVal+' autocomplete="off" />');
      var pwdPlaceholder = $(input).siblings('.login-input');
      pwdPlaceholder.show();
      pwdField.hide();

      pwdPlaceholder.focus(function(){
          pwdPlaceholder.hide();
          pwdField.show();
          pwdField.focus();
      });

      pwdField.blur(function(){
          if(pwdField.val() == '') {
              pwdPlaceholder.show();
              pwdField.hide();
          }
      });
      
  };
  
  function initPlaceHolder(){
	//当浏览器不支持placeholder属性时，调用placeholder函数
	  if(!supportPlaceholder){
	 
	    $('input').each(function(){
	    	if($(this).attr("type") == "text"){
	    		placeholder($(this));
	    	}
	    	if($(this).attr("type") == "password"){
	    		placeholderPWD($(this));
	    	}
	    });
	    
	  }
  }

  initPlaceHolder();